package com.huyanqi.front.rest.resource.impl;

import java.util.List;

import javax.annotation.Resource;

import com.huyanqi.core.RetdObj;
import com.huyanqi.entity.Shop;
import com.huyanqi.front.rest.RespCode;
import com.huyanqi.front.rest.resource.ShopListResource;
import com.huyanqi.front.rest.resp.ShopListResp;
import com.huyanqi.front.rest.resp.ShopSimpleResp;
import com.huyanqi.front.rest.service.ShopRestService;

public class ShopResourceImpl implements ShopListResource{

	private ShopRestService restService;
	
	@Resource(name="ShopRestService")
	public void setRestService(ShopRestService restService) {
		this.restService = restService;
	}
	public ShopRestService getRestService() {
		return restService;
	}
	
	@Override
	public ShopListResp findShopBySetId(Long setid, Integer pageSize,Integer pageNum) {
		ShopListResp slp = new ShopListResp();
		try{
			RetdObj<List<Shop>> retdObj = restService.findShopBySetId(setid,pageSize,pageNum); 
			slp.setData(retdObj.getRealObj());
			slp.setCode(RespCode.valueOf(retdObj.getCode()));
		}catch (Exception e) {
			e.printStackTrace();
			slp.setCode(RespCode.EX_APP);
		}
		return slp;
	}
	
	@Override
	public ShopSimpleResp findShopBySid(Long shopid,Long uid) {
		ShopSimpleResp ssr = new ShopSimpleResp();
		RetdObj<Shop> retd = restService.findShopBySid(shopid,uid);
		ssr.setResult(retd.getRealObj());
		ssr.setCode(RespCode.valueOf(retd.getCode()));
		return ssr;
	}
	
}
